package com.axt.dbaudit.action.query;

import java.util.List;
import org.apache.struts2.json.annotations.JSON;

import com.axt.dbaudit.bean.query.QueryAlarmBean;
import com.axt.dbaudit.bean.query.QuerySessionBean;
import com.axt.dbaudit.model.query.Alarm;
import com.axt.dbaudit.model.query.AlarmDetail;
import com.axt.dbaudit.model.query.Session;
import com.axt.dbaudit.model.query.SessionDetail;
import com.axt.dbaudit.model.query.SessionDetailHead;
import com.axt.soa.msg.types.*;

public class QueryAlarmAction extends QueryBaseAction {
	private QueryAlarmBean queryAlarmBean = new QueryAlarmBean();
	private List<Alarm> alarms = null;
	List<AlarmDetail> alarmDetails = null;
	
	@JSON(name="alarms")
	public List<Alarm> getAlarms() {
		return alarms;
	}
	
	void setAlarms(List<Alarm> alarms) {
		this.alarms = alarms;
	}
	
	@JSON(name="alarmdetails")
	public List<AlarmDetail> getAlarmDetails() {
		return alarmDetails;
	}
	
	void setAlarmDetail(List<AlarmDetail> alarmDetails){
		this.alarmDetails = alarmDetails;
	}
	
	@JSON(name="totalRows")
	public int getTotalRows() {
		return totalRows;
	}
	
	@JSON(name="queryProgress")
	public String getQueryProgress() {
		return queryProgress;
	}
	
	@JSON(name="queryDate")
	public String getQueryDate() {
		return queryDate;
	}
	
	@JSON(name="errcode")
	public int getErrcode() {
		return errcode;
	}
	
	@JSON(name="errinfo")
	public String getErrinfo() {
		return errinfo;
	}

	/* 报警查询 */
	public String queryAlarms() {
		
		/* 查询报警索引 */
		queryAlarmBean.queryAlarmIndices(serverPath, filters, queryInResult, maxRowNum);
		
		setErrcode(queryAlarmBean.getErrcode());
		setErrinfo(queryAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;

	}
	
	/* 停止查询 */
	public String stopQuery() {
		
		/* 停止查询报警索引 */
		queryAlarmBean.stopQueryIndices(serverPath);
		
		setErrcode(queryAlarmBean.getErrcode());
		setErrinfo(queryAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;

	}
	
	public String queryProcess(){
		/* 获取查询进度 */
		queryAlarmBean.queryProcess(serverPath, filters);
		
		setQueryProgress(queryAlarmBean.getQueryProgress());
		setQueryDate(queryAlarmBean.getQueryDate());
		setErrcode(queryAlarmBean.getErrcode());
		setErrinfo(queryAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	public String queryAlarmData(){
		/* 查询结果 */
		queryAlarmBean.queryAlarms(serverPath, filters);
		setAlarms(queryAlarmBean.getAlarms());
		setErrcode(queryAlarmBean.getErrcode());
		setErrinfo(queryAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	public String queryAlarmDetail(){
		/* 查询会话详细信息  */
		queryAlarmBean.queryAlarmDetail(serverPath, filters);
		setAlarmDetail(queryAlarmBean.getAlarmDetails());
		setErrcode(queryAlarmBean.getErrcode());
		setErrinfo(queryAlarmBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
}
